/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package generadorva;

import ec.util.MersenneTwisterFast;
import java.io.PrintWriter;

/**
 *
 * @author USUARIO
 */
public class Ejemplo2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        MersenneTwisterFast prng = new MersenneTwisterFast(6548752);
        BoxMuller normal = new BoxMuller(100.0,16.0);
        double sumab = 0;
        double sumab2 = 0;
        int n = 100000;
        try {
            PrintWriter out = new PrintWriter("salida2.txt");
            for (int i = 0; i < n; i++) {
                int tiempoEntrega = TiempoEntrega.generar(prng.nextDouble());
                double dti = 0;
                for (int j = 0; j < tiempoEntrega; j++) {
                    dti +=  normal.generate(prng);
                }
                out.println(dti);
                sumab += dti;
                sumab2 += dti*dti;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        
        double media = sumab / n;
        double varianza = (sumab2 - n*media*media)/((n-1)*1d);
        System.out.println("media = " + media);
        System.out.println("varianza = " + varianza);
    }
}
